/*
 *------------------------------------------------------------------------------
 * @File      :    wks70002_lvds.c
 * @Date      :    2021-3-20
 * @Author    :    lomboswer <lomboswer@lombotech.com>
 * @Brief     :    Source file for MDP(Media Development Platform).
 *
 * Copyright (C) 2020-2021, LomboTech Co.Ltd. All rights reserved.
 *------------------------------------------------------------------------------
 */
#include "ei_comm_panel.h"
#include <fcntl.h>
#include "panel_usr.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

static VO_PUB_ATTR_S wks70002_config = {
    .enIntfType = VO_INTF_LVDS_JEIDA_24BIT,
    .enIntfSync = VO_OUTPUT_USER,
    .BufferSmooth = (-1U),
    .stSyncInfo.bDataMirror = 0, /* MSB first */

    .stSyncInfo.bIop = 1,
    .stSyncInfo.u16Hfb = 160,
    .stSyncInfo.u16Hpw = 100,
    .stSyncInfo.u16Hbb = 100,
    .stSyncInfo.u16Hact = 1024,
    .stSyncInfo.u16Vfb = 12,
    .stSyncInfo.u16Vpw = 13,
    .stSyncInfo.u16Vbb = 23,
    .stSyncInfo.u16Vact = 600,
    .stSyncInfo.u32Pclk = 59400, /* 59.4 kHz */
};

static VO_PUB_ATTR_S wks70002_dual_link_config = {
    .enIntfType = VO_INTF_LVDS_JEIDA_24BIT,
    .enIntfSync = VO_OUTPUT_USER,
    .BufferSmooth = (-1U),
    .stSyncInfo.bDataMirror = 0, /* MSB first */
    .stSyncInfo.bDual = 1,

    .stSyncInfo.bIop = 1,
    .stSyncInfo.u16Hfb = 160,
    .stSyncInfo.u16Hpw = 100,
    .stSyncInfo.u16Hbb = 100,
    .stSyncInfo.u16Hact = 2048,
    .stSyncInfo.u16Vfb = 12,
    .stSyncInfo.u16Vpw = 13,
    .stSyncInfo.u16Vbb = 23,
    .stSyncInfo.u16Vact = 600,
    .stSyncInfo.u32Pclk = 99000, /* 90 kHz */
};

EI_S32 panel_wks70002_get_panel_attr(PANEL_TYPE_E enPanelType, PANEL_TYPE_ATTR_S *pstPanelAttr)
{
    switch (enPanelType) {
    case WKS70002_LVDS_1024_600_60FPS:
        pstPanelAttr->stVoPubAttr = wks70002_config;
        break;
    case WKS70002_LVDS_1024_600_60FPS_DUAL_LINK:
        pstPanelAttr->stVoPubAttr = wks70002_dual_link_config;
        break;
    default:
        EI_TRACE_DOSS(EI_DBG_INFO, "invalid panel id\n");
        return EI_ERR_VO_ILLEGAL_PARAM;
    }

    return EI_SUCCESS;
}

PANEL_OBJ_S stPanelWks70002Obj = {
    .pfnGetPanelAttrByPanel = panel_wks70002_get_panel_attr,
    .pfnGetPanelInitCodeByPanel = NULL,
};

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

